/**
 * 
 */
package helpers;

import model.ModelShop;

public class IDGenerator {

	public static long id = 0;

	private IDGenerator() {

	}

	public static long generateID(ModelShop modelShop) throws Exception {

		// Check, welches die höchste vergebene ID ist.
		for (fpt.com.Product p : modelShop) {
			if (p.getId() > id) {
				id = p.getId();
			}
		}
		id++;

		if (id > 999999) {
			throw new Exception("Can not create product (invalid ID: > 999999)");
		}
		return id;
	}

}
